package com.hdax.dmw.order.api;

import com.hdax.dmw.common.utils.Result;
import com.hdax.dmw.common.utils.TokenUtil;
import com.hdax.dmw.order.dtos.LinkUserDto;
import com.hdax.dmw.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(path = "/order/p/")
public class OrderConfirmApi {

    @Autowired
    private OrderService orderService;

    //查询当前登录用户的所有联系人
    @PostMapping(path = "ticketbuyerlist")
    public Result<List<LinkUserDto>> ticketBuyerList(HttpServletRequest request){
        String token = request.getHeader("token");
        Map<String, String> tokenMap = TokenUtil.parseToken(token);
        long userId = Long.parseLong(tokenMap.get("id"));
        return orderService.linkUserList(userId);
    }
}
